﻿using com.guojin.core.io;
using com.guojin.core.io.message;

namespace com.guojin.mj.net.message.login
{
    //登录信息
    public class LoginReq : Message
    {
        public static int TYPE = 7;
        public static int ID = 8;

        public string type { get; set; }           //"ANONYMOUS"匿名登录  "WEIXIN"微信登录  "TOKEN" token登录
        public string token { get; set; }        //token登录时发送，匿名和微信登录为null;
        public string wxCode { get; set; }    //wx登录时发送，匿名和token登录为null;
        public string longitude { get; set; }   //经度
        public string latitude { get; set; }      //纬度

        public void decode(Input _in)
        {
        }

        public void encode(Output _out)
        {
            _out.writeString(type);
            _out.writeString(token);
            _out.writeString(wxCode);
            _out.writeString(longitude);
            _out.writeString(latitude);
        }

        public string toString()
        {
            return "LoginReq [type=" + type + ",openId=" + token + ",wxCode=" + wxCode + ",longitude=" + longitude +
                   ",latitude=" + latitude + ", ]";
        }

        public int getMessageId()
        {
            return ID;
        }

        public int getMessageType()
        {
            return TYPE;
        }

        public static LoginReq create(string type, string token, string wxCode, string longitude, string latitude)
        {
            var login = new LoginReq();
            login.type = type;
            login.token = token;
            login.wxCode = wxCode;
            login.longitude = longitude;
            login.latitude = latitude;
            return login;
        }
    }
}